<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
    <script>
        // function getData(a) {
        //     a++;
        //     $.get("1.php",function (res) {
        //         console.log(res);
        //         getData(a);
        //     })
        // }
        // getData(1);

        // function testStack(a) {
        //     debugger;
        //     a++;
        //     testStack(a);
        // }
        // testStack(1);

        function sleep(time) {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve(true);
                }, time);
            });
        }

        async function testStack2(a) {
            a++;
            await sleep(1000);
            testStack2(a);
        }

        testStack2(1);
    </script>
</body>

</html>